package com.kun.base.util

import android.content.Context

/**
 * @author ZGL on 2018/8/21
 */
class ContextUtils private constructor() {
    companion object {
        private var mContext: Context? = null

        /**
         * 初始化工具类
         *
         * @param context 上下文
         */
        fun init(context: Context) {
            mContext = context.applicationContext
        }

        /**
         * 获取ApplicationContext
         *
         * @return ApplicationContext
         */
        @JvmStatic
        val context: Context?
            get() {
                if (mContext != null) {
                    return mContext
                }
                throw NullPointerException("u should init first")
            }
    }

    init {
        throw UnsupportedOperationException("u can't instantiate me...")
    }
}